#ifndef _BMS_DEMO_H_
#define _BMS_DEMO_H_

// Voltage thresholds (in millivolts)
#define LOW_VOLTAGE_ALARM    3300    // Threshold for low voltage alarm
#define LOW_VOLTAGE_PROTECT  3000    // Threshold for low voltage protection
#define HIGH_VOLTAGE_PROTECT 4250    // Threshold for high voltage protection

// Temperature thresholds (in degrees Celsius)
#define OVER_TEMPERATURE  60     // Threshold for over temperature protection
#define UNDER_TEMPERATURE -40    // Threshold for under temperature protection

#define CHARGE_LOWER_TEMP 0
#define CHARGE_UPPER_TEMP 59

#define DISCHARGE_LOWER_TEMP -20
#define DISCHARGE_UPPER_TEMP 59

#define IDLE_LOWER_TEMP 60
#define IDLE_UPPER_TEMP -40

// Charge thresholds
#define CHARGE_CURRENT_THRESHOLD      350     // Maximum current (in mA) to consider the battery as potentially fully charged.
#define CHARGE_FULL_VOLTAGE_THRESHOLD 4150    // Minimum cell voltage (in mV) to consider the battery as potentially fully charged.
#define CHARGE_COUNT_THRESHOLD        5       // Number of consecutive measurements needed to confirm the battery is fully charged.
#define CHARGE_TIMER_THRESHOLD        100     // Number of consecutive measurements to detect the charging mode based on GPIO pin states.


#define LOW_VOLTAGE_BALANCE  3300    // Threshold for low voltage balance
#define HIGH_VOLTAGE_BALANCE 4200    // Threshold for high voltage balance


// Function prototypes for state handling functions
void BMS_Init(void);
void BMS_SelfTest(void);
void BMS_Idle(void);
void BMS_Charging(void);
void BMS_Discharging(void);
void BMS_Fault(void);
void BMS_Protect(void);
void BMS_UnknownMode(void);


void Wrok_Demo(void);
void key_init(void);
void demo_Init(void);
void demo_Init(void);



#endif    // _BMS_DEMO_H_